@import './variables.less';

@menuWidth: 210px;

.setMenuActive() {
  &.active {
    > a {
      color: @primary-color;
      background: #fff;
    }
  }
}

.toggleMenuClass() {
  > .btn-toggle {
    font-size: 20px;
    padding-bottom: 5px;
    display: inline-block;
    text-align: right;
    width: 100%;

    i {
      padding-right: 11px;
      background-color: @primary-color;
      padding: 8px;
      margin-right: 3px;
      cursor: pointer;
    }

    &:hover {
      i {
        background: @primary-color*1.2;
        padding: 8px;
        border-radius: 4px;
      }
    }
  }
}

.layout {
  font-size: 14px;

  > .menus {
    width: @menuWidth;
    color: #fff;
    padding-top: 12px;
    background-color: @primary-color;
    border-right: 1px solid @primary-color;
    user-select: none;
    .toggleMenuClass();

    > .nav-list {
      list-style: none;
      padding-left: 0;
      max-height: 540px;
      overflow-y: auto;

      a,
      a:hover,
      a:focus {
        color: #fff;
        display: flex;
        flex-flow: row nowrap;
        width: 100%;
        padding: 4px 0px;
        line-height: 14px;
        vertical-align: middle;
        text-decoration: none;
        background-color: @primary-color;

        > span {
          flex: 1;
          padding-left: 8px;
          line-height: 32px;
          vertical-align: middle;
        }
      }

      .nav-item {
        width: @menuWidth;
        display: inline-block;
        margin-bottom: 2px;
        line-height: 36px;
        vertical-align: middle;
        white-space: nowrap;

        > a {
          cursor: pointer;
          padding: 4px 4px;
          line-height: 18px;
          background: @primary-color*1.068;

          &:hover {
            background-color: @primary-color*1.32;
          }

          > .menu-icon {
            &:before {
              width: 32px;
              height: 32px;
              display: inline-block;
              text-align: center;
            }

            font-size: 22px;
            top: 6px;
            left: 1px;
            line-height: 18px;
            padding: 0;
            position: relative;
          }

          > b {
            float: right;
            width: 18px;
            padding-top: 6px;
            padding-right: 4px;
            line-height: 24px;
            vertical-align: middle;
          }
        }

        &.open {
          > a {
            font-weight: bold;
            background-color: @primary-color*1.28;
          }

          > ul.submenu {
            display: inline-block;
            width: 100%;
          }
        }

        ul.submenu {
          display: none;
          list-style: none;
          margin: 0;
          padding: 0;

          .dropdown-toggle {
            cursor: pointer;
            background-color: @primary-color*1.06;

            > span {
              line-height: 14px;
            }

            > .arrow {
              float: right;
              margin-right: 10px;
            }
          }

          ul.submenu {
            width: 100%;
            display: inline-block;

            > li {
              > a {
                padding-left: 30px;
              }
            }
          }

          .menu-icon {
            font-size: 10px;
          }

          > li {
            &:first-of-type {
              margin-top: 3px;
            }

            > a {
              padding: 10px 0;
              padding-left: 15px;

              &:hover {
                background: @primary-color*1.28;
              }

              > i {
                padding-right: 8px;
              }
            }

            .setMenuActive();
          }
        }

        .has-children {
          .dropdown-toggle {
            cursor: default !important;

            > .menu-text {
              padding-left: 0;
            }
          }
        }
      }

      > .nav-item {
        &.active {
          > a {
            font-weight: bold;
            background-color: @primary-color*1.48;
          }
        }
      }
    }

    &.mobile-menus {
      display: inline-block !important;
      position: absolute;
      z-index: 999;
      top: 50px;

      > .btn-toggle {
        display: none;
      }

      > .nav-list {
        padding-top: 5px;
      }
    }
  }

  &.collapse-menus {
    > .menus {
      width: 52px;
      display: inline-block;

      > .nav-list {
        a {
          color: #fff;
          background: @primary-color;

          > .menu-icon {
            &:before {
              line-height: 32px;
            }

            padding: 5px;
          }

          > span {
            display: none;
          }

          > b {
            display: none;
          }
        }

        > .nav-item {
          &:hover,
          &.hover {
            > a {
              background: @primary-color;

              > .menu-icon {
                border-radius: 5px;
                background: @primary-color * 1.2;
              }
            }
          }

          &.open {
            > ul.submenu {
              display: none;
            }
          }

          &.active {
            a {
              background: @primary-color;

              > .menu-icon {
                border-radius: 5px;
                color: @primary-color;
                background: #fff;
              }
            }
          }
        }

        > ul.submenu {
          display: none;
        }
      }
    }

    > .main-content {
      width: calc(100% - 52px);
    }

    > .popover-menus {
      top: 51px;
      left: 51px;
      display: none;
      position: absolute;
      background-color: #fff;
      padding: 0;
      width: 250px;
      z-index: 100;
      border-radius: 0 8px 8px 0;
      border: 1px solid @primary-color*0.818;

      > b {
        width: 100%;
        font-size: 16px;
        color: #333;
        display: inline-block;
        padding: 5px 10px;
        text-align: left;
        margin-bottom: 0;
      }

      > a {
        color: @text-color-85;
        font-weight: bold;
        font-size: 16px;
        width: 100%;
        padding: 10px 15px;
        display: inline-block;

        &:not([href]):hover {
          cursor: default;
          text-decoration: none;
        }

        > .menu-icon {
          display: inline-block;
          margin-right: 5px;
        }

        > b {
          display: none;
        }
      }

      .has-children {
        .dropdown-toggle {
          line-height: 1;
          padding: 5px 10px 5px 20px;
          vertical-align: middle;
          color: #0f3675;
          cursor: default !important;
          background-color: #fff;
          width: 100%;
          display: flex;
          align-items: center;
          font-weight: bold;

          > span {
            flex: 1;
          }

          > b.arrow {
            vertical-align: middle;
            margin-right: 0px;
            position: relative;
            top: -2px;
          }
        }

        > .submenu {
          padding: 0 0;

          > li {
            padding-left: 15px;
          }
        }
      }

      .submenu {
        width: 100%;
        list-style: none;
        line-height: 22px;
        display: inline-block;
        padding: 0;
        margin-top: 2px;

        .dropdown-toggle {
          cursor: pointer;

          > .arrow {
            float: right;
            margin-top: 5px;
            margin-right: 5px;
          }
        }

        .submenu {
          background: #fff;

          a {
            padding-left: 20px;
          }

          li {
            background: #fff;
          }
        }

        a {
          width: 100%;
          line-height: 24px;
          vertical-align: middle;
          padding: 8px 15px 8px 20px;

          > .menu-icon {
            margin-right: 5px;
            display: none;
          }
        }

        > li {
          &.active {
            background: #b9dbfd;

            a {
              font-size: 14px;
              font-weight: 500;
              color: #1e91e8;
            }
          }
        }
      }
    }
  }
}
